package com.wlient.basic.Thread.test;

import java.util.ArrayList;
import java.util.List;

class Solution {
    public static int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];
        for(int i=0;i<nums.length;i++){
            for(int j=0;j<nums.length-1;j++){
                if(nums[i]+nums[j]==target){
                    result[0] = i;
                    result[1] = j;
                }
            }
        }
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,9,45};
        int target = 54;
        System.out.println(Solution.twoSum(nums,target)[1]);

        System.out.println(solution2(1000,3));

        System.out.println(Solution.printNumbers(5).length);
    }

    public static int solution2(int nLevel, int kChess) {
        if (kChess == 1) {
            return nLevel;
        }
        int[][] dp = new int[nLevel + 1][kChess + 1];
        for (int i = 1; i != dp.length; i++) {
            dp[i][1] = i;
        }
        for (int i = 1; i != dp.length; i++) {
            for (int j = 2; j != dp[0].length; j++) {
                int min = Integer.MAX_VALUE;
                for (int k = 1; k != i + 1; k++) {
                    min = Math.min(min,
                            Math.max(dp[k - 1][j - 1], dp[i - k][j]));
                }
                dp[i][j] = min + 1;
            }
        }
        return dp[nLevel][kChess];
    }


    public static int[] printNumbers(int n) {
        if(n <= 0){
            return new int[0];
        }
        int num = 0 ;
        StringBuilder tmp = new StringBuilder();
        for (int i = 1; i <= n; i++){
            num += Math.pow(10,i-1) * 9;
        }

        int[] arr = new int[num];
        for (int i = 0;i < num; i++){
            arr[i] = i+1;
        }
        return arr;
    }

}